import { AnyAction } from 'redux'
import { handleActions } from 'redux-actions'
import { homeUpdateState } from '@redux/action/homeActions'

export interface HomeStore {
  countryList: any[]; // 国家列表
  lipisList: any[]; // 国旗列表
  keyWord: ''
}

const initHomeState: HomeStore = {
  countryList: [],
  lipisList: [],
  keyWord: ''
}

const homeReducer = handleActions({
  [homeUpdateState]: (state: HomeStore, action: AnyAction) => ({
    ...state,
    ...action.payload
  })
}, initHomeState)

export default homeReducer
